﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "dwgobject.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
enum DrawType
{
    DNone,
    DPoint,
    DLine,
    DCircle
};
enum ModifyType
{
    MNone,
    MSelect,
    MDelete
};

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    QVector<DwgObject *> m_mainlist;
    DrawType mCurDrawType = DNone;
    ModifyType mCurModifyType = MNone;
    QPainter *mpainter = nullptr;
    qreal m_winScale = 1.0;            	// 用于记录视图缩放的比例的变量
    QTransform m_trans;                	// 用于记录当前视图的变换矩阵的变量

    void DrawCoordinate(QPainter *painter);

private:
    Ui::MainWindow *ui;


    // QWidget interface
protected:
    virtual void paintEvent(QPaintEvent *event);
private slots:
    void on_actionPoint_triggered();
    void on_actionLine_triggered();
    void on_actionCircle_triggered();

    // QWidget interface
    void on_actionNew_triggered();

    void on_actionExit_triggered();

    void on_actionSelect_triggered();

    void on_actionDelete_triggered();

protected:
    virtual void mousePressEvent(QMouseEvent *event);

    // QWidget interface
protected:
    virtual void wheelEvent(QWheelEvent *event);


    // QWidget interface
protected:
    virtual void mouseMoveEvent(QMouseEvent *event);

};
#endif // MAINWINDOW_H
